/**
  ******************************************************************************
  * @author     Chris
  * @since      2024/6/18 16:18
  *
  * @file       pd_exti.h
  * @brief      Header file of External Interrupt hardware driver.
  *
  * @note       This file contains the External Interrupt object declaration.
  *
  * @warning    None.
  ******************************************************************************
  * Change Logs:
  *   Date          Author       Notes
  *   2024/6/18     Chris        the first version
  *
  ******************************************************************************
  */


#ifndef JLC_SKY_EXTI_H
#define JLC_SKY_EXTI_H

#include <stm32f4xx.h>
#include "pd_gpio.h"

struct ExtIRVtbl;

/** @defgroup Object properties
  * @{
  */
typedef struct {
    GPIO *gpio;
    uint32_t Port;
    uint32_t Line;

    uint32_t Line_0_31;
    FunctionalState LineCommand;
    uint8_t Mode;
    uint8_t Trigger;

    // ExternalTI virtual table
    struct ExtIRVtbl *vptr;
} ExtIR;
/**
 * @}
 */

/** @defgroup Object virtual table definition
  * @{
  */
struct ExtIRVtbl {
    void (*init)(const ExtIR *this, IRQn_Type irQnType, uint32_t PreemptPriority, uint32_t SubPriority);
};
/**
 * @}
 */

/** @defgroup Object constructor and member function declaration
  * @{
  */
void ExtIR_constructor(ExtIR *this, GPIO *gpio, uint32_t Line_0_31, uint32_t Port, uint32_t Line);
/**
 * @}
 */

/** @defgroup Object virtual table function implementation
  * @{
  */
static inline void ExtIR_init(const ExtIR *this, IRQn_Type irQnType, uint32_t PreemptPriority, uint32_t SubPriority) {
    this->vptr->init(this, irQnType, PreemptPriority, SubPriority);
}
/**
 * @}
 */


#endif //JLC_SKY_EXTI_H
